

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>Lua Scripting &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="D3N RGW Data Cache" href="../d3n_datacache/" />
    <link rel="prev" title="Ceph s3 select" href="../s3select/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 对象网关</a> &raquo;</li>
        
      <li>Lua Scripting</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/radosgw/lua-scripting.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 对象网关</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../frontends/">HTTP 前端</a></li>
<li class="toctree-l2"><a class="reference internal" href="../placement/">存储池归置与存储类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../multisite/">多站配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../multisite-sync-policy/">多站同步策略配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pools/">存储池的配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config-ref/">配置参考</a></li>
<li class="toctree-l2"><a class="reference internal" href="../admin/">管理指南</a></li>
<li class="toctree-l2"><a class="reference internal" href="../s3/">S3 API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rgw-cache/">Data caching and CDN</a></li>
<li class="toctree-l2"><a class="reference internal" href="../swift/">Swift API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../adminops/">管理操作 API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">Python 接口</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nfs/">通过 NFS 导出</a></li>
<li class="toctree-l2"><a class="reference internal" href="../keystone/">与 OpenStack Keystone 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../barbican/">与 OpenStack Barbican 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vault/">与 HashiCorp Vault 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kmip/">KMIP Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../opa/">与 Open Policy Agent 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../multitenancy/">多租户</a></li>
<li class="toctree-l2"><a class="reference internal" href="../compression/">压缩</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ldap-auth/">LDAP 认证</a></li>
<li class="toctree-l2"><a class="reference internal" href="../encryption/">服务器端加密</a></li>
<li class="toctree-l2"><a class="reference internal" href="../bucketpolicy/">桶策略</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dynamicresharding/">动态的桶索引重分片</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mfa/">多因子认证</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sync-modules/">同步模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../notifications/">Bucket Notifications</a></li>
<li class="toctree-l2"><a class="reference internal" href="../layout/">RADOS 中的数据布局</a></li>
<li class="toctree-l2"><a class="reference internal" href="../STS/">STS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../STSLite/">STS Lite</a></li>
<li class="toctree-l2"><a class="reference internal" href="../keycloak/">Keycloak</a></li>
<li class="toctree-l2"><a class="reference internal" href="../role/">Role</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session-tags/">Session Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="../orphans/">Orphan List and Associated Tooliing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../oidc/">OpenID Connect Provider</a></li>
<li class="toctree-l2"><a class="reference internal" href="../troubleshooting/">故障排除</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../man/8/radosgw/">radosgw 手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../man/8/radosgw-admin/">radosgw-admin 手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../qat-accel/">使用 QAT 为加密和压缩提速</a></li>
<li class="toctree-l2"><a class="reference internal" href="../s3select/">S3-select</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Lua Scripting</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#script-management-via-cli">Script Management via CLI</a></li>
<li class="toctree-l3"><a class="reference internal" href="#package-management-via-cli">Package Management via CLI</a></li>
<li class="toctree-l3"><a class="reference internal" href="#context-free-functions">Context Free Functions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#debug-log">Debug Log</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#request-fields">Request Fields</a></li>
<li class="toctree-l3"><a class="reference internal" href="#request-functions">Request Functions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#operations-log">Operations Log</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#lua-code-samples">Lua Code Samples</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../d3n_datacache/">D3N Data Cache</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cloud-transition/">Cloud Transition</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="lua-scripting">
<h1><a class="toc-backref" href="#id1">Lua Scripting</a><a class="headerlink" href="#lua-scripting" title="Permalink to this headline">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified added">New in version Pacific.</span></p>
</div>
<div class="contents topic" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#lua-scripting" id="id1">Lua Scripting</a></p>
<ul>
<li><p><a class="reference internal" href="#script-management-via-cli" id="id2">Script Management via CLI</a></p></li>
<li><p><a class="reference internal" href="#package-management-via-cli" id="id3">Package Management via CLI</a></p></li>
<li><p><a class="reference internal" href="#context-free-functions" id="id4">Context Free Functions</a></p>
<ul>
<li><p><a class="reference internal" href="#debug-log" id="id5">Debug Log</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#request-fields" id="id6">Request Fields</a></p></li>
<li><p><a class="reference internal" href="#request-functions" id="id7">Request Functions</a></p>
<ul>
<li><p><a class="reference internal" href="#operations-log" id="id8">Operations Log</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#lua-code-samples" id="id9">Lua Code Samples</a></p></li>
</ul>
</li>
</ul>
</div>
<p>This feature allows users to upload Lua scripts to different context in the radosgw. The two supported context are “preRequest” that will execute a script before the
operation was taken, and “postRequest” that will execute after each operation is taken. Script may be uploaded to address requests for users of a specific tenant.
The script can access fields in the request and modify some fields. All Lua language features can be used in the script.</p>
<p>By default, all lua standard libraries are available in the script, however, in order to allow for other lua modules to be used in the script, we support adding packages to an allowlist:</p>
<blockquote>
<div><ul class="simple">
<li><p>All packages in the allowlist are being re-installed using the luarocks package manager on radosgw restart. Therefore a restart is needed for adding or removing of packages to take effect</p></li>
<li><p>To add a package that contains C source code that needs to be compiled, use the <cite>–allow-compilation</cite> flag. In this case a C compiler needs to be available on the host</p></li>
<li><p>Lua packages are installed in, and used from, a directory local to the radosgw. Meaning that lua packages in the allowlist are separated from any lua packages available on the host.
By default, this directory would be <cite>/tmp/luarocks/&lt;entity name&gt;</cite>. Its prefix part (<cite>/tmp/luarocks/</cite>) could be set to a different location via the <cite>rgw_luarocks_location</cite> configuration parameter.
Note that this parameter should not be set to one of the default locations where luarocks install packages (e.g. <cite>$HOME/.luarocks</cite>, <cite>/usr/lib64/lua</cite>, <cite>/usr/share/lua</cite>)</p></li>
</ul>
</div></blockquote>
<div class="toctree-wrapper compound">
</div>
<div class="section" id="script-management-via-cli">
<h2><a class="toc-backref" href="#id2">Script Management via CLI</a><a class="headerlink" href="#script-management-via-cli" title="Permalink to this headline">¶</a></h2>
<p>To upload a script:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script put --infile={lua-file} --context={preRequest|postRequest} [--tenant={tenant-name}]</span>
</pre></div>
</div>
<p>To print the content of the script to standard output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script get --context={preRequest|postRequest} [--tenant={tenant-name}]</span>
</pre></div>
</div>
<p>To remove the script:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script rm --context={preRequest|postRequest} [--tenant={tenant-name}]</span>
</pre></div>
</div>
</div>
<div class="section" id="package-management-via-cli">
<h2><a class="toc-backref" href="#id3">Package Management via CLI</a><a class="headerlink" href="#package-management-via-cli" title="Permalink to this headline">¶</a></h2>
<p>To add a package to the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package add --package={package name} [--allow-compilation]</span>
</pre></div>
</div>
<p>To add a specific version of a package to the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package add --package=&#39;{package name} {package version}&#39; [--allow-compilation]</span>
</pre></div>
</div>
<ul class="simple">
<li><p>When adding a diffrent version of a package which already exists in the list, the newly
added version will override the existing one.</p></li>
<li><p>When adding a package without a version specified, the latest version of the package
will be added.</p></li>
</ul>
<p>To remove a package from the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package rm --package={package name}</span>
</pre></div>
</div>
<p>To remove a specific version of a package from the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package rm --package=&#39;{package name} {package version}&#39;</span>
</pre></div>
</div>
<ul class="simple">
<li><p>When removing a package without a version specified, any existing versions of the
package will be removed.</p></li>
</ul>
<p>To print the list of packages in the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package list</span>
</pre></div>
</div>
</div>
<div class="section" id="context-free-functions">
<h2><a class="toc-backref" href="#id4">Context Free Functions</a><a class="headerlink" href="#context-free-functions" title="Permalink to this headline">¶</a></h2>
<div class="section" id="debug-log">
<h3><a class="toc-backref" href="#id5">Debug Log</a><a class="headerlink" href="#debug-log" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">RGWDebugLog()</span></code> function accepts a string and prints it to the debug log with priority 20.
Each log message is prefixed <code class="docutils literal notranslate"><span class="pre">Lua</span> <span class="pre">INFO:</span></code>. This function has no return value.</p>
</div>
</div>
<div class="section" id="request-fields">
<h2><a class="toc-backref" href="#id6">Request Fields</a><a class="headerlink" href="#request-fields" title="Permalink to this headline">¶</a></h2>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This feature is experimental. Fields may be removed or renamed in the future.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>Although Lua is a case-sensitive language, field names provided by the radosgw are case-insensitive. Function names remain case-sensitive.</p></li>
<li><p>Fields marked “optional” can have a nil value.</p></li>
<li><p>Fields marked as “iterable” can be used by the pairs() function and with the # length operator.</p></li>
<li><p>All table fields can be used with the bracket operator <code class="docutils literal notranslate"><span class="pre">[]</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">time</span></code> fields are strings with the following format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span> <span class="pre">%H:%M:%S</span></code>.</p></li>
</ul>
</div>
<table class="docutils align-default">
<colgroup>
<col style="width: 34%" />
<col style="width: 6%" />
<col style="width: 40%" />
<col style="width: 6%" />
<col style="width: 7%" />
<col style="width: 6%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Field</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Iterable</p></th>
<th class="head"><p>Writeable</p></th>
<th class="head"><p>Optional</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.RGWOp</span></code></p></td>
<td><p>string</p></td>
<td><p>radosgw operation</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.DecodedURI</span></code></p></td>
<td><p>string</p></td>
<td><p>decoded URI</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ContentLength</span></code></p></td>
<td><p>integer</p></td>
<td><p>size of the request</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.GenericAttributes</span></code></p></td>
<td><p>table</p></td>
<td><p>string to string generic attributes map</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Response</span></code></p></td>
<td><p>table</p></td>
<td><p>response to the request</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Response.HTTPStatusCode</span></code></p></td>
<td><p>integer</p></td>
<td><p>HTTP status code</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Response.HTTPStatus</span></code></p></td>
<td><p>string</p></td>
<td><p>HTTP status text</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Response.RGWCode</span></code></p></td>
<td><p>integer</p></td>
<td><p>radosgw error code</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Response.Message</span></code></p></td>
<td><p>string</p></td>
<td><p>response message</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.SwiftAccountName</span></code></p></td>
<td><p>string</p></td>
<td><p>swift account name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket</span></code></p></td>
<td><p>table</p></td>
<td><p>info on the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Tenant</span></code></p></td>
<td><p>string</p></td>
<td><p>tenant of the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Name</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Marker</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket marker (initial id)</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Count</span></code></p></td>
<td><p>integer</p></td>
<td><p>number of objects in the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Size</span></code></p></td>
<td><p>integer</p></td>
<td><p>total size of objects in the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.ZoneGroupId</span></code></p></td>
<td><p>string</p></td>
<td><p>zone group of the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.CreationTime</span></code></p></td>
<td><p>time</p></td>
<td><p>creation time of the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.MTime</span></code></p></td>
<td><p>time</p></td>
<td><p>modification time of the bucket</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Quota</span></code></p></td>
<td><p>table</p></td>
<td><p>bucket quota</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Quota.MaxSize</span></code></p></td>
<td><p>integer</p></td>
<td><p>bucket quota max size</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Quota.MaxObjects</span></code></p></td>
<td><p>integer</p></td>
<td><p>bucket quota max number of objects</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Reques.Bucket.Quota.Enabled</span></code></p></td>
<td><p>boolean</p></td>
<td><p>bucket quota is enabled</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.Quota.Rounded</span></code></p></td>
<td><p>boolean</p></td>
<td><p>bucket quota is rounded to 4K</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.PlacementRule</span></code></p></td>
<td><p>table</p></td>
<td><p>bucket placement rule</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.PlacementRule.Name</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket placement rule name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.PlacementRule.StorageClass</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket placement rule storage class</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.User</span></code></p></td>
<td><p>table</p></td>
<td><p>bucket owner</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.User.Tenant</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket owner tenant</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Bucket.User.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket owner id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object</span></code></p></td>
<td><p>table</p></td>
<td><p>info on the object</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object.Name</span></code></p></td>
<td><p>string</p></td>
<td><p>object name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object.Instance</span></code></p></td>
<td><p>string</p></td>
<td><p>object version</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>object id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object.Size</span></code></p></td>
<td><p>integer</p></td>
<td><p>object size</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Object.MTime</span></code></p></td>
<td><p>time</p></td>
<td><p>object mtime</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.CopyFrom</span></code></p></td>
<td><p>table</p></td>
<td><p>information on copy operation</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.CopyFrom.Tenant</span></code></p></td>
<td><p>string</p></td>
<td><p>tenant of the object copied from</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.CopyFrom.Bucket</span></code></p></td>
<td><p>string</p></td>
<td><p>bucket of the object copied from</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.CopyFrom.Object</span></code></p></td>
<td><p>table</p></td>
<td><p>object copied from. See: <code class="docutils literal notranslate"><span class="pre">Request.Object</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ObjectOwner</span></code></p></td>
<td><p>table</p></td>
<td><p>object owner</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ObjectOwner.DisplayName</span></code></p></td>
<td><p>string</p></td>
<td><p>object owner display name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ObjectOwner.User</span></code></p></td>
<td><p>table</p></td>
<td><p>object user. See: <code class="docutils literal notranslate"><span class="pre">Request.Bucket.User</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ZoneGroup.Name</span></code></p></td>
<td><p>string</p></td>
<td><p>name of zone group</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ZoneGroup.Endpoint</span></code></p></td>
<td><p>string</p></td>
<td><p>endpoint of zone group</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Owner</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL owner. See: <code class="docutils literal notranslate"><span class="pre">Request.ObjectOwner</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL map of string to grant
note: grants without an Id are not presented when iterated
and only one of them can be accessed via brackets</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;]</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL grant</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].Type</span></code></p></td>
<td><p>integer</p></td>
<td><p>user ACL grant type</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].User</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL grant user</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].User.Tenant</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL grant user tenant</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].User.Id</span></code></p></td>
<td><p>table</p></td>
<td><p>user ACL grant user id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].GroupType</span></code></p></td>
<td><p>integer</p></td>
<td><p>user ACL grant group type</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserAcl.Grants[&quot;&lt;name&gt;&quot;].Referer</span></code></p></td>
<td><p>string</p></td>
<td><p>user ACL grant referer</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.BucketAcl</span></code></p></td>
<td><p>table</p></td>
<td><p>bucket ACL. See: <code class="docutils literal notranslate"><span class="pre">Request.UserAcl</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.ObjectAcl</span></code></p></td>
<td><p>table</p></td>
<td><p>object ACL. See: <code class="docutils literal notranslate"><span class="pre">Request.UserAcl</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Environment</span></code></p></td>
<td><p>table</p></td>
<td><p>string to string environment map</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Policy</span></code></p></td>
<td><p>table</p></td>
<td><p>policy</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Policy.Text</span></code></p></td>
<td><p>string</p></td>
<td><p>policy text</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Policy.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>policy Id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>yes</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Policy.Statements</span></code></p></td>
<td><p>table</p></td>
<td><p>list of string statements</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserPolicies</span></code></p></td>
<td><p>table</p></td>
<td><p>list of user policies</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.UserPolicies[&lt;index&gt;]</span></code></p></td>
<td><p>table</p></td>
<td><p>user policy. See: <code class="docutils literal notranslate"><span class="pre">Request.Policy</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.RGWId</span></code></p></td>
<td><p>string</p></td>
<td><p>radosgw host id: <code class="docutils literal notranslate"><span class="pre">&lt;host&gt;-&lt;zone&gt;-&lt;zonegroup&gt;</span></code></p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP</span></code></p></td>
<td><p>table</p></td>
<td><p>HTTP header</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Parameters</span></code></p></td>
<td><p>table</p></td>
<td><p>string to string parameter map</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Resources</span></code></p></td>
<td><p>table</p></td>
<td><p>string to string resource map</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Metadata</span></code></p></td>
<td><p>table</p></td>
<td><p>string to string metadata map</p></td>
<td><p>yes</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Host</span></code></p></td>
<td><p>string</p></td>
<td><p>host name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Method</span></code></p></td>
<td><p>string</p></td>
<td><p>HTTP method</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.URI</span></code></p></td>
<td><p>string</p></td>
<td><p>URI</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.QueryString</span></code></p></td>
<td><p>string</p></td>
<td><p>HTTP query string</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.HTTP.Domain</span></code></p></td>
<td><p>string</p></td>
<td><p>domain name</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Time</span></code></p></td>
<td><p>time</p></td>
<td><p>request time</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Dialect</span></code></p></td>
<td><p>string</p></td>
<td><p>“S3” or “Swift”</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>request Id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.TransactionId</span></code></p></td>
<td><p>string</p></td>
<td><p>transaction Id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.Tags</span></code></p></td>
<td><p>table</p></td>
<td><p>object tags map</p></td>
<td><p>yes</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.User</span></code></p></td>
<td><p>table</p></td>
<td><p>user that triggered the request</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Request.User.Tenant</span></code></p></td>
<td><p>string</p></td>
<td><p>triggering user tenant</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Request.User.Id</span></code></p></td>
<td><p>string</p></td>
<td><p>triggering user id</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
<td><p>no</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="request-functions">
<h2><a class="toc-backref" href="#id7">Request Functions</a><a class="headerlink" href="#request-functions" title="Permalink to this headline">¶</a></h2>
<div class="section" id="operations-log">
<h3><a class="toc-backref" href="#id8">Operations Log</a><a class="headerlink" href="#operations-log" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">Request.Log()</span></code> function prints the requests into the operations log. This function has no parameters. It returns 0 for success and an error code if it fails.</p>
</div>
</div>
<div class="section" id="lua-code-samples">
<h2><a class="toc-backref" href="#id9">Lua Code Samples</a><a class="headerlink" href="#lua-code-samples" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p>Print information on source and destination objects in case of copy:</p></li>
</ul>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">function</span> <span class="nf">print_object</span><span class="p">(</span><span class="n">object</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Name: &quot;</span> <span class="o">..</span> <span class="n">object</span><span class="p">.</span><span class="n">Name</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Instance: &quot;</span> <span class="o">..</span> <span class="n">object</span><span class="p">.</span><span class="n">Instance</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Id: &quot;</span> <span class="o">..</span> <span class="n">object</span><span class="p">.</span><span class="n">Id</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Size: &quot;</span> <span class="o">..</span> <span class="n">object</span><span class="p">.</span><span class="n">Size</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  MTime: &quot;</span> <span class="o">..</span> <span class="n">object</span><span class="p">.</span><span class="n">MTime</span><span class="p">)</span>
<span class="kr">end</span>

<span class="kr">if</span> <span class="n">Request</span><span class="p">.</span><span class="n">CopyFrom</span> <span class="ow">and</span> <span class="n">Request</span><span class="p">.</span><span class="n">Object</span> <span class="ow">and</span> <span class="n">Request</span><span class="p">.</span><span class="n">CopyFrom</span><span class="p">.</span><span class="n">Object</span> <span class="kr">then</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;copy from object:&quot;</span><span class="p">)</span>
  <span class="n">print_object</span><span class="p">(</span><span class="n">Request</span><span class="p">.</span><span class="n">CopyFrom</span><span class="p">.</span><span class="n">Object</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;to object:&quot;</span><span class="p">)</span>
  <span class="n">print_object</span><span class="p">(</span><span class="n">Request</span><span class="p">.</span><span class="n">Object</span><span class="p">)</span>
<span class="kr">end</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Print ACLs via a “generic function”:</p></li>
</ul>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">function</span> <span class="nf">print_owner</span><span class="p">(</span><span class="n">owner</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;Owner:&quot;</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Dispaly Name: &quot;</span> <span class="o">..</span> <span class="n">owner</span><span class="p">.</span><span class="n">DisplayName</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Id: &quot;</span> <span class="o">..</span> <span class="n">owner</span><span class="p">.</span><span class="n">User</span><span class="p">.</span><span class="n">Id</span><span class="p">)</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  Tenanet: &quot;</span> <span class="o">..</span> <span class="n">owner</span><span class="p">.</span><span class="n">User</span><span class="p">.</span><span class="n">Tenant</span><span class="p">)</span>
<span class="kr">end</span>

<span class="kr">function</span> <span class="nf">print_acl</span><span class="p">(</span><span class="n">acl_type</span><span class="p">)</span>
  <span class="n">index</span> <span class="o">=</span> <span class="n">acl_type</span> <span class="o">..</span> <span class="s2">&quot;ACL&quot;</span>
  <span class="n">acl</span> <span class="o">=</span> <span class="n">Request</span><span class="p">[</span><span class="n">index</span><span class="p">]</span>
  <span class="kr">if</span> <span class="n">acl</span> <span class="kr">then</span>
    <span class="n">RGWDebugLog</span><span class="p">(</span><span class="n">acl_type</span> <span class="o">..</span> <span class="s2">&quot;ACL Owner&quot;</span><span class="p">)</span>
    <span class="n">print_owner</span><span class="p">(</span><span class="n">acl</span><span class="p">.</span><span class="n">Owner</span><span class="p">)</span>
    <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;  there are &quot;</span> <span class="o">..</span> <span class="o">#</span><span class="n">acl</span><span class="p">.</span><span class="n">Grants</span> <span class="o">..</span> <span class="s2">&quot; grant for owner&quot;</span><span class="p">)</span>
    <span class="kr">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="kr">in</span> <span class="nb">pairs</span><span class="p">(</span><span class="n">acl</span><span class="p">.</span><span class="n">Grants</span><span class="p">)</span> <span class="kr">do</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant Key: &quot;</span> <span class="o">..</span> <span class="n">k</span><span class="p">)</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant Type: &quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">.</span><span class="n">Type</span><span class="p">)</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant Group Type: &quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">.</span><span class="n">GroupType</span><span class="p">)</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant Referer: &quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">.</span><span class="n">Referer</span><span class="p">)</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant User Tenant: &quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">.</span><span class="n">User</span><span class="p">.</span><span class="n">Tenant</span><span class="p">)</span>
      <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;    Grant User Id: &quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">.</span><span class="n">User</span><span class="p">.</span><span class="n">Id</span><span class="p">)</span>
    <span class="kr">end</span>
  <span class="kr">else</span>
    <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;no &quot;</span> <span class="o">..</span> <span class="n">acl_type</span> <span class="o">..</span> <span class="s2">&quot; ACL in request: &quot;</span> <span class="o">..</span> <span class="n">Request</span><span class="p">.</span><span class="n">Id</span><span class="p">)</span>
  <span class="kr">end</span>
<span class="kr">end</span>

<span class="n">print_acl</span><span class="p">(</span><span class="s2">&quot;User&quot;</span><span class="p">)</span>
<span class="n">print_acl</span><span class="p">(</span><span class="s2">&quot;Bucket&quot;</span><span class="p">)</span>
<span class="n">print_acl</span><span class="p">(</span><span class="s2">&quot;Object&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Use of operations log only in case of errors:</p></li>
</ul>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">if</span> <span class="n">Request</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">HTTPStatusCode</span> <span class="o">~=</span> <span class="mi">200</span> <span class="kr">then</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;request is bad, use ops log&quot;</span><span class="p">)</span>
  <span class="n">rc</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">Log</span><span class="p">()</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;ops log return code: &quot;</span> <span class="o">..</span> <span class="n">rc</span><span class="p">)</span>
<span class="kr">end</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Set values into the error message:</p></li>
</ul>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">if</span> <span class="n">Request</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">HTTPStatusCode</span> <span class="o">==</span> <span class="mi">500</span> <span class="kr">then</span>
  <span class="n">Request</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Message</span> <span class="o">=</span> <span class="s2">&quot;&lt;Message&gt; something bad happened :-( &lt;/Message&gt;&quot;</span>
<span class="kr">end</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Add metadata to objects that was not originally sent by the client:</p></li>
</ul>
<p>In the <cite>preRequest</cite> context we should add:</p>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">if</span> <span class="n">Request</span><span class="p">.</span><span class="n">RGWOp</span> <span class="o">==</span> <span class="s1">&#39;put_obj&#39;</span> <span class="kr">then</span>
  <span class="n">Request</span><span class="p">.</span><span class="n">HTTP</span><span class="p">.</span><span class="n">Metadata</span><span class="p">[</span><span class="s2">&quot;x-amz-meta-mydata&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;my value&quot;</span>
<span class="kr">end</span>
</pre></div>
</div>
<p>In the <cite>postRequest</cite> context we look at the metadata:</p>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;number of metadata entries is: &quot;</span> <span class="o">..</span> <span class="o">#</span><span class="n">Request</span><span class="p">.</span><span class="n">HTTP</span><span class="p">.</span><span class="n">Metadata</span><span class="p">)</span>
<span class="kr">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="kr">in</span> <span class="nb">pairs</span><span class="p">(</span><span class="n">Request</span><span class="p">.</span><span class="n">HTTP</span><span class="p">.</span><span class="n">Metadata</span><span class="p">)</span> <span class="kr">do</span>
  <span class="n">RGWDebugLog</span><span class="p">(</span><span class="s2">&quot;key=&quot;</span> <span class="o">..</span> <span class="n">k</span> <span class="o">..</span> <span class="s2">&quot;, &quot;</span> <span class="o">..</span> <span class="s2">&quot;value=&quot;</span> <span class="o">..</span> <span class="n">v</span><span class="p">)</span>
<span class="kr">end</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Use modules to create Unix socket based, JSON encoded, “access log”:</p></li>
</ul>
<p>First we should add the following packages to the allowlist:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># radosgw-admin script-package add --package=luajson</span>
<span class="c1"># radosgw-admin script-package add --package=luasocket --allow-compilation</span>
</pre></div>
</div>
<p>Then, do a restart for the radosgw and upload the following script to the <cite>postRequest</cite> context:</p>
<div class="highlight-lua notranslate"><div class="highlight"><pre><span></span><span class="kr">if</span> <span class="n">Request</span><span class="p">.</span><span class="n">RGWOp</span> <span class="o">==</span> <span class="s2">&quot;get_obj&quot;</span> <span class="kr">then</span>
  <span class="kd">local</span> <span class="n">json</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s2">&quot;json&quot;</span><span class="p">)</span>
  <span class="kd">local</span> <span class="n">socket</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s2">&quot;socket&quot;</span><span class="p">)</span>
  <span class="kd">local</span> <span class="n">unix</span> <span class="o">=</span> <span class="nb">require</span><span class="p">(</span><span class="s2">&quot;socket.unix&quot;</span><span class="p">)</span>
  <span class="kd">local</span> <span class="n">s</span> <span class="o">=</span> <span class="nb">assert</span><span class="p">(</span><span class="n">unix</span><span class="p">())</span>
  <span class="n">E</span> <span class="o">=</span> <span class="p">{}</span>

  <span class="n">msg</span> <span class="o">=</span> <span class="p">{</span><span class="n">bucket</span> <span class="o">=</span> <span class="p">(</span><span class="n">Request</span><span class="p">.</span><span class="n">Bucket</span> <span class="ow">or</span> <span class="p">(</span><span class="n">Request</span><span class="p">.</span><span class="n">CopyFrom</span> <span class="ow">or</span> <span class="n">E</span><span class="p">).</span><span class="n">Bucket</span><span class="p">).</span><span class="n">Name</span><span class="p">,</span>
    <span class="n">time</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">Time</span><span class="p">,</span>
    <span class="n">operation</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">RGWOp</span><span class="p">,</span>
    <span class="n">http_status</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">HTTPStatusCode</span><span class="p">,</span>
    <span class="n">error_code</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">HTTPStatus</span><span class="p">,</span>
    <span class="n">object_size</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">Object</span><span class="p">.</span><span class="n">Size</span><span class="p">,</span>
    <span class="n">trans_id</span> <span class="o">=</span> <span class="n">Request</span><span class="p">.</span><span class="n">TransactionId</span><span class="p">}</span>

  <span class="nb">assert</span><span class="p">(</span><span class="n">s</span><span class="p">:</span><span class="n">connect</span><span class="p">(</span><span class="s2">&quot;/tmp/socket&quot;</span><span class="p">))</span>
  <span class="nb">assert</span><span class="p">(</span><span class="n">s</span><span class="p">:</span><span class="n">send</span><span class="p">(</span><span class="n">json</span><span class="p">.</span><span class="n">encode</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span><span class="o">..</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">))</span>
  <span class="nb">assert</span><span class="p">(</span><span class="n">s</span><span class="p">:</span><span class="n">close</span><span class="p">())</span>
<span class="kr">end</span>
</pre></div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../d3n_datacache/" class="btn btn-neutral float-right" title="D3N RGW Data Cache" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../s3select/" class="btn btn-neutral float-left" title="Ceph s3 select" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>